#include"shellsort.h"
#include<stdio.h>
int Swap(int* a,int* b){
  int* temp=a;
  a=b;
  b=temp;
}
// 希尔排序
void ShellSort(int* arr, int n){
  int gap=n;
  while(gap>1){
    gap=gap/2;
    int i=0;
    for(i=0;i<gap;i++){
      int j=0;
      for(j=i;j<n-gap;j+=gap){
        int end=j;
        int tmp=arr[j+gap];
        while(end>=0){
         if(tmp<arr[end]){
           arr[end+gap]=arr[end];
           end-=gap;
         }
         else{
           break;
         }
       }
       arr[end+gap]=tmp;
      }
    }
  }
}
int main(){
  int array[]={1,3,5,7,9,2,4,6,8,0};
  int n=sizeof(array)/sizeof(int);
  ShellSort(array,n);
  int i=0;
  for(i=0;i<n;i++){
    printf("%d ",array[i]);
  }
  printf("\n");
  return 0;
}
